package com.manong.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.manong.dao.ShopMapper;
import com.manong.dao.SupMapper;
import com.manong.entity.Shop;
import com.manong.entity.Sup;
import com.manong.service.ShopService;
import com.manong.service.SupService;
import com.manong.vo.query.ShopVo;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Service;

@Service
public class ShopServiceImpl extends ServiceImpl<ShopMapper, Shop> implements ShopService {
    /**
     * 根据供应商名称分页查询商品信息
     * @param page
     * @param shopVo
     * @return
     */
    @Override
    public IPage<Shop> findSupListByUsername(IPage<Shop> page, ShopVo shopVo) {
        QueryWrapper<Shop> queryWrapper = new QueryWrapper<Shop>();
        queryWrapper.like(!ObjectUtils.isEmpty(shopVo.getSupname()),"supname",shopVo.getSupname())
                .like(!ObjectUtils.isEmpty(shopVo.getUsername()),"username",shopVo.getUsername());
        return baseMapper.selectPage(page,queryWrapper);
    }
    /**
     * 根据id删除
     * @param id
     * @return
     */
    @Override
    public boolean deleteById(Long id) {
        return baseMapper.deleteById(id)>0;
    }

    @Override
    public IPage<Shop> findOrderListByUsername(IPage<Shop> page, ShopVo shopVo) {
        QueryWrapper<Shop> queryWrapper = new QueryWrapper<Shop>();
        queryWrapper.like(!ObjectUtils.isEmpty(shopVo.getName()),"name",shopVo.getName())
                .like(!ObjectUtils.isEmpty(shopVo.getUsername()),"username",shopVo.getUsername())
                .eq("status",shopVo.getStatus());
        return baseMapper.selectPage(page,queryWrapper);
    }
}
